<!DOCTYPE html> 
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta charset="utf-8">
<title>商户信息</title>
<link href="jquery-mobile/jquery.mobile.min.css" rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.raty.js"></script>

<script type="text/javascript" src="js/baiduAPI.js"></script>
<link href="css/bmap.css" rel="stylesheet" type="text/css"/>

<script src="js/cordova.js" type="text/javascript"></script>
<script src="js/getcomment.js"></script>
<script src="js/getshopinfo.js" type="text/javascript"></script>

<script type="text/javascript" src="js/UcarV1.js"></script>

<script type="text/javascript">
$(window).load(function() {
	//$('#back').attr("href", "index.html?type=" + request("type") + "&lng=" + $("#lng").html() + "&lat=" + $("#lat").html());
});

$(document).ready(function(){

});
</script>

<style type="text/css">
#main {
	background:url("img/back.jpg") repeat;
}

#comment {
	background-color: white;
	border-radius: 15px;
	border-style: solid;
	border-color: white;
	border-width: 1px;
}

table tr {
	border-bottom: solid;
	border-bottom-color: #222;
	border-bottom-width: 2px;
}

table td {
	padding: 0 5px;
}

.left {
	float: left;
	padding: 10px;
}

.clear {
	clear: both;
}

#shopdetails {
	background-color: white; 
	border-radius: 15px;
	border: solid gray 1px;
}

#moreComment {
	height: 114px;
}
</style>
</head>

<body>

<div id="main" data-role="page">

<div data-role="header" data-theme="b">
    <a href="" id="back" rel="external">返回</a>
    <h1>商铺详情</h1>
    <a href="#" onclick=postcollect()>收藏</a>
</div>

<div data-role="content">
 <div>
   <div id="shopstar">
   	
   </div>
 </div>
 <div>
    <table>
     <tr>
      <td id="shopinfo">
        
      </td>
     </tr>
    </table>
 </div>
 	  	
 
 <div>
 <br>
   <input type="button" data-theme="e" value="分享与点评" onclick="share()" />
 <br>
 </div>
 
  <div id="comment"></div>
  
</div>
<script type="text/javascript">
var type=request("type");
var shopid=request("shopid");
var shopname="默认店铺名";
var lat=0;
var lng=0;

	showshop(shopid, type);
	showcomment(shopid, type);
	
function postcollect(){
	checklogin();
}


function checklogin() {
	document.addEventListener("deviceready", onDeviceReady, false);
    // PhoneGap is ready
    function onDeviceReady() {
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
    }

    function gotFS(fileSystem) {
        fileSystem.root.getFile("ucar/DataFile.txt", {create: true}, gotFileEntry, fail);
    }

    function gotFileEntry(fileEntry) {
        fileEntry.file(gotFile, fail);
    }

    function gotFile(file){
        readAsText(file);
    }

    function readAsText(file) {
		var reader = new FileReader();
        reader.onloadend = function(evt) {
            var arg=evt.target.result.split(";");
			

            if (arg==""){
                // Empty file. Not Logined.
                 alert("您仍未登录，请先登录，才可以添加收藏");
								window.location.href ='login.html';
            }
			
			
			 	var arg1=arg[0].split("=");
				 var arg2=arg[1].split("=");
				 var uid1=arg1[1];
				 $.ajax({type:'POST',async:false, url:'http://ihavecar.sinaapp.com/postcollect.php?shopid='+shopid+'&type='+type+'&userid='+uid1});
				 alert("成功添加收藏");
			
        };
        reader.readAsText(file);	
    }

    function fail(evt) {
    		$("#sina").css("background-position", "0 -16px");
				alert("您仍未登录，请先登录，才可以进行点评与分享");
				window.location.href ='login.html';
				console.log("Detect as NOT logined.");
        console.log(evt.target.error.code);
    }
}
function share(){ 
	window.location.href=encodeURI('share.html?type='+type+'&shopid='+shopid+'&shopname='+shopname+'&lat='+lat+'&lng='+lng);
}
</script>
</div>
</body>
</html>